package com.zhou.common.mybatis.template.shiro.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.zhou.common.lib.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户会话
 *
 * @author ruoyi
 */
@AllArgsConstructor
@Getter
public enum OnlineStatus implements BaseEnum<Integer> {
    /**
     * 用户状态
     */
    on_line(0, "在线"), off_line(1, "离线");

    @EnumValue
    @JsonValue
    private final Integer code;

    private final String info;

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static OnlineStatus getItem(Integer code) {
        for (OnlineStatus item : values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }


    @Override
    public String toString() {
        return String.format("%s-%s", code, info);
    }
}
